﻿@namespace MudBlazor
@using MudBlazor.Resources
@typeparam T
@inherits MudComponentBase
@inject InternalMudLocalizer Localizer

<div tabindex="0" role="@RoleAttribute" @attributes="UserAttributes" class="@Classname" style="@Style" @onclick="EventUtil.AsNonRenderingEventHandler<MouseEventArgs>(OnClickAsync)">
    @{
        if (AvatarContent is not null)
        {
            @AvatarContent
        }
        else if (!string.IsNullOrEmpty(Icon) && !ShowCheckMark)
        {
            <MudIcon Disabled="@Disabled" Icon="@Icon" Class="mud-chip-icon" Size="MudBlazor.Size.Small" Color="@GetIconColor()" />
        }
        else if (ShowCheckMark)
        {
            <MudIcon Disabled="@Disabled" Icon="@GetCheckedIcon()" Class="mud-chip-icon" Size="MudBlazor.Size.Small" />
        }
    }
    <span class="mud-chip-content">
        @if (ChildContent is null)
        {
            @if(Text is null) {
                @($"{Value}")
            }
            else {
                @Text
            }
        }
        else
        {
            @ChildContent
        }
        @if (OnClose.HasDelegate || ChipSet?.AllClosable == true)
        {
            <MudIconButton Class="mud-chip-close-button" Icon="@GetCloseIcon()" OnClick="OnCloseAsync" Size="MudBlazor.Size.Small"
                           aria-label="@Localizer[LanguageResource.MudChip_Close]" />
        }
    </span>
</div>
